package mirrormonkey.util.netevent;

import junit.framework.Assert;

import mirrormonkey.util.netevent.EventManager;
import mirrormonkey.util.netevent.message.tools.MockMessageListener;

import org.junit.Test;

import com.jme3.network.Message;

public class EventManagerTest {

	private static EventManager manager = new EventManager();

	/**
	 * Tests if removing the last class specific MessageListener does remove the
	 * class from the map
	 */
	@Test
	public void testSpecificEventCleanup() {
		MockMessageListener l = new MockMessageListener();
		MockMessageListener l2 = new MockMessageListener();
		manager.addMessageListener(l, Message.class);
		manager.addMessageListener(l2, Message.class);
		Assert.assertEquals(1, manager.getMessageClassCount());
		manager.removeMessageListener(l2, Message.class);
		Assert.assertEquals(1, manager.getMessageClassCount());
		manager.removeMessageListener(l, Message.class);
		Assert.assertEquals(0, manager.getMessageClassCount());
	}

}
